import axios from "axios";

import { BASE_URL, TIMEOUT } from "./config";
 
class Axios {
    constructor(baseURL,timeOUT)
    {
        this.instance = axios.create({
            baseURL,
            timeOUT
        })
        
        //响应拦截
        this.instance.interceptors.response.use(res => res.data, err => err);
    }

    request(config)
    {
        return this.instance.request(config);
    }

    get(config)
    {
      return this.instance.request({...config,method:"get"})
    }

    post(config)
    { 
       return this.instance.request({...config,method:"post"})
    }
}

const MyAxios = new Axios(BASE_URL, TIMEOUT);
export default MyAxios;